<template>
  <base-breadcrumb>
    <searchData
      :search-data="searchArr"
      @search="search"
    />

    <a-card :bordered="false">
      <!-- <title-name title="项目停缓建/停工申请列表" /> -->

      <div class="table-operator">
        <a-button
          v-btnPermission="'pm_025_add_01'"
          type="primary"
          @click="handelAdd"
        >
          新增停缓建/停工申请
        </a-button>
      </div>

      <div class="pub-table-select-count">
        <a-icon
          type="info-circle"
          theme="twoTone"
        />
        <span style="margin-right: 12px"> 总申请数：<span class="totalNum">{{ totalDels.total	}} 个</span> |
          停工/停缓建审核中：<span class="totalNum">{{ totalDels.stoppageSubmittedNum }} 个</span> |
          停工/停缓建审核不通过 ：<span class="totalNum">{{ totalDels.stoppageRejectedNum	}} 个</span> |
          停工/停缓建：<span class="totalNum">{{ totalDels.stoppagePassNum }} 个</span> |
          重新开工/复工审核中 ：<span class="totalNum">{{ totalDels.resumeWorkSubmittedNum }} 个</span> |
          在建 ：<span class="totalNum">{{ totalDels.resumeWorkPassNum }} 个</span>
        </span>
      </div>

      <list-table
        ref="table"
        bordered
        size="default"
        row-key="key"
        :columns="columns"
        :request="loadData"
        :alert="true"
        show-size-changer
        show-quick-jumper
        show-pagination="auto"
      >
        <span
          slot="serial"
          slot-scope="text, record, index"
        >{{ index + 1 }}</span>
        <span
          slot="status"
          slot-scope="text"
        >
          <a-badge
            :status="text | statusTypeFilter"
            :text="text | statusFilter"
          />
        </span>
        <span
          slot="description"
          slot-scope="text"
        >
          <ellipsis
            :length="8"
            tooltip
          >{{ text }}</ellipsis>
        </span>
        <span
          slot="action"
          slot-scope="text, record"
        >
          <template>
            <MoreButton>
              <a
                v-btnPermission="'pm_025_loo_02'"
                @click="handleDels(record)"
              >查看</a>
              <template>
                <a v-if="record.status == 'SLOW_REVIEW_REJECTED' || record.status == 'STOP_REVIEW_REJECTED'"
                  v-btnPermission="'pm_025_edi_03'"
                  @click="handleEdit(record)"
                >编辑</a>
              </template>
              <template>
                <a v-if="record.status == 'SLOW_REVIEW_PAST'" 
                  v-btnPermission="'pm_025_aga_04'"
                  @click="handleReturnWork(record, 'RESUME')"
                >复工申请</a>
              </template>
              <template>
                <a v-if="record.status == 'STOP_REVIEW_PAST'" 
                  v-btnPermission="'pm_025_aga_04'"
                  @click="handleReturnWork(record, 'START')"
                >重新开工</a>
              </template>

              <template>
                <a
                  v-btnPermission="'pm_025_moi_05'"
                  @click="handleApproveDetail(record)"
                > 审批信息</a>
              </template>
            </MoreButton>
          </template>
        </span>
      </list-table>

      <!-- 停缓建/停工信息 - 弹窗 -->
      <a-modal
        v-if="visible"
        width="900px"
        destroy-on-close
        :visible="true"
        :title="title"
        @cancel="visible=false"
      >
        <title-name title="停缓建/停工信息" />
        <template slot="footer">
          <a-button
            key="back"
            @click="handleCancel"
          >
            关闭
          </a-button>
          <a-button
            key="submit"
            :loading="loading"
            type="primary"
            @click="handleOk"
          >
            提交审批
          </a-button>
        </template>
        <a-form-model
          ref="form1"
          :model="form"
          :rules="rules1"
        >
          <a-row>
            <a-col :span="12">
              <a-form-model-item
                label="所属单位"
                :label-col="{ lg: { span: 5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
                prop="projectId"
              >
                <org-tree-select
                  v-model="form.projectId"
                  is-auto-select-first
                  is-need-auth
                  check-strictly
                  is-special-tree
                  :is-query-projec-detail="false"
                  :status-set="[1, 2, 3, 4]"
                  :exclude-business-set="!!businessId ? [businessId]: []"
                  :extra-query="{
                    ifProjectStopWork: 1,
                    auditStatus: 2
                  }"
                  @select="selectOrg"
                />
              </a-form-model-item>
            </a-col>
            <a-col
              :md="12"
              :sm="12"
            >
              <a-form-model-item
                label="当前形象进度"
                :label-col="{ lg: { span: 5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
                prop="imageProgress"
              >
                <BaseInput
                  v-model="form.imageProgress"
                  :maxLength="300"
                />
              </a-form-model-item>
            </a-col>
            <a-col
              :md="12"
              :sm="12"
            >
              <a-form-model-item
                label="类型"
                :label-col="{ lg: { span:5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
                prop="stoppageType"
              >
                <a-select
                  v-model="form.stoppageType"
                  placeholder="请选择"
                >
                  <a-select-option value="STOP"> 停工 </a-select-option>
                  <a-select-option value="SLOW"> 停缓建 </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="12"
              :sm="12"
              v-if="form.stoppageType == 'SLOW'"
            >
              <a-form-model-item
                label="是否经过董常会"
                :label-col="{ lg: { span:5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
                prop="ifDongChang"
              >
                <a-select
                  v-model="form.ifDongChang"
                  placeholder="请选择"
                >
                  <a-select-option :value="true">是</a-select-option>
                  <a-select-option :value="false">否</a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="12"
              :sm="12"
            >
              <a-form-model-item
                label="停缓建/停工原因"
                :label-col="{ lg: { span:5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
                prop="stopReasonId"
              >
                <a-select
                  v-model="form.stopReasonId"
                  placeholder="请选择"
                >
                  <a-select-option
                    v-for="item in reasons"
                    :key="item.id"
                    :value="item.id"
                  >
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="12"
              :sm="12"
            >
              <a-form-model-item
                label="停缓建/停工时间"
                :label-col="{ lg: { span: 5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
                prop="stopDate"
              >
                <a-date-picker
                  v-model="form.stopDate"
                  style="width: 100%"
                  format="YYYY-MM-DD"
                  @change="onChangeDown"
                />
              </a-form-model-item>
            </a-col>
            <a-col
              :md="12"
              :sm="12"
            >
              <a-form-model-item
                label="预计复工时间"
                :label-col="{ lg: { span:5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
                prop="resumeWorkDate"
              >
                <!-- <a-date-picker @change="onChangeReturn" v-model="form.resumeWorkDate" style="width: 100%"/> -->
                <a-date-picker
                  v-model="form.resumeWorkDate"
                  format="YYYY-MM-DD"
                  @change="onChangeReturn"
                />
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col
              :md="24"
              :sm="24"
            >
              <a-form-model-item
                label="情况说明"
                :label-col="{ lg: { span: 5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
                prop="situationComment"
              >
                <BaseTextarea
                  v-model="form.situationComment"
                  placeholder="请输入情况说明"
                />
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col
              :md="12"
              :sm="12"
            >
              <a-form-model-item
                label="创建人"
                :label-col="{ lg: { span: 5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
              >
                <BaseInput
                  v-model="form.creater"
                  disabled
                />
              </a-form-model-item>
            </a-col>
            <a-col
              :md="12"
              :sm="12"
            >
              <a-form-model-item
                label="创建时间"
                :label-col="{ lg: { span:5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
              >
                <BaseInput
                  v-model="form.createTime"
                  disabled
                />
              </a-form-model-item>
            </a-col>
          </a-row>

          <title-name title="上传相关附件" />
          <u-table
            :list-url="listUrl"
            :upload-arrys="uploadArrys"
            :req-method="reqMethod"
            :upload-list="uploadList"
            :delete-url="deleteUrl"
            business-code="PM14"
            @fileArrysData="fileArrysData"
          />
        </a-form-model>
      </a-modal>

      <!-- 开工/复工信息 - 弹窗 -->
      <a-modal
        v-if="visibles"
        width="900px"
        destroy-on-close
        :visible="true"
        :title="titles"
        @cancel="visibles=false"
      >
        <title-name title="重新开工/复工信息" />
        <template slot="footer">
          <a-button
            key="back"
            @click="handleCancels"
          >
            关闭
          </a-button>
          <a-button
            key="submit"
            :loading="loading"
            type="primary"
            @click="handleOks"
          >
            提交审批
          </a-button>
        </template>
        <a-form-model
          ref="form2"
          :model="forms"
          :rules="rules2"
        >
          <a-row>
            <a-col
              :md="24"
              :sm="24"
            >
              <a-form-model-item
                label="所属单位"
                :label-col="{ lg: { span: 5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
              >
                <BaseInput
                  v-model="forms.viewName"
                  type="text"
                  disabled
                />
              </a-form-model-item>
            </a-col>
           
          </a-row>
          <!-- <a-row>
            <a-col
              :md="12"
              :sm="12"
            >
              <a-form-model-item
                label="项目编号"
                :label-col="{ lg: { span: 5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
              >
                <BaseInput
                  v-model="forms.projectNum"
                  type="text"
                  disabled
                />
              </a-form-model-item>
            </a-col>
          </a-row> -->
          <a-row>
            <a-col
              :md="24"
              :sm="24"
            >
              <a-form-model-item
                label="情况说明"
                :label-col="{ lg: { span: 5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
                prop="situationComment"
              >
                <BaseTextarea
                  v-model="forms.situationComment"
                  placeholder="请输入情况说明"
                />
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col
              :md="12"
              :sm="12"
            >
              <a-form-model-item
                label="申请人"
                :label-col="{ lg: { span: 5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
              >
                <BaseInput
                  v-model="forms.creater"
                  disabled
                />
              </a-form-model-item>
            </a-col>
            <a-col
              :md="12"
              :sm="12"
            >
              <a-form-model-item
                label="申请时间"
                :label-col="{ lg: { span:5 }, sm: { span: 5 } }"
                :wrapper-col="{ lg: { span: 18 }, sm: { span: 18 } }"
              >
                <BaseInput
                  v-model="forms.createTime"
                  disabled
                />
              </a-form-model-item>
            </a-col>
          </a-row>

          <title-name title="上传相关附件" />
          <u-table
            :list-url="listUrls"
            :upload-arrys="uploadArrys"
            :req-method="reqMethod"
            :upload-list="uploadList"
            :delete-url="deleteUrl"
            :if-stop-construction="true"
            business-code="PM23"
            @fileArrysData="fileArrysDatas"
          />
        </a-form-model>
      </a-modal>

      <ApprovalDetails
        :title="'审批详情'"
        :business-id="businessId1"
        :visible="visibleApprove"
        @cancel="visibleApprove = false"
        @confirm="visibleApprove = false"
      />
      <!-- 选择审批人 -->
      <selectApprover
        :business-id="businessId2"
        :process-config="setProcessConfig"
        :is-close-upper="false"
        @close="closeSelectApprover"
      />
      <!-- 选择审批人 -->
    </a-card>
  </base-breadcrumb>
</template>

<script>
import { STable, Ellipsis } from '@/components'
import { workStoppageApplyDetail, resumeWorkApply, queryWorkStoppageStatistics, queryWorkStoppageApply, workStoppageApplySave, workStoppageApplyEdit, returnApplication, getProjectCommon } from '@/api/project/stopConstruction'
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/SelectProjects/SelectProject' // 项目
import OrgTreeSelect from '@/components/OrgTreeSelect'
import ApprovalDetails from './approvalDetails'
import cloneDeep from 'lodash.clonedeep'

import ARow from 'ant-design-vue/es/grid/Row'
import moment from 'moment'

const columns = [
  {
    title: '序号',
    width: 65,
    scopedSlots: { customRender: 'serial' }
  },
  {
    title: '类型',
    dataIndex: 'type'
  },
  {
    title: '项目名称',
    dataIndex: 'projectName'
  },
  // {
  //   title: '项目编号',
  //   dataIndex: 'projectNum'
  // },
  {
    title: '分公司',
    dataIndex: 'branchComName'
  },
  {
    title: '停缓建/停工原因',
    dataIndex: 'stopReason'
  },
  {
    title: '停缓建/停工时间',
    dataIndex: 'stopTime'
  },
  {
    title: '预计复工时间',
    dataIndex: 'resumeTime'
  },
  {
    title: '创建人',
    dataIndex: 'creatorName'
  },
  {
    title: '创建时间',
    dataIndex: 'createTime'
  },
  {
    title: '状态',
    dataIndex: 'statusName'
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: '150px',
    fixed: 'right',
    scopedSlots: { customRender: 'action' }
  }
]

export default {
  name: 'a' + Date.now(),
  components: {
    ARow,
    STable,
    Ellipsis,
    ApprovalDetails,
    SelectSubCompany,
    SelectProject
  },
  data() {
    return {
      loading: false,
      visibleApprove: false,

      columns,
      searchArr: [
        // 搜索框
        {
          name: '所属单位',
          valueKey: 'searchQuery',
          type: OrgTreeSelect,
        },
        // {
        //   name: '项目名称',
        //   value: 'projectName',
        //   type: 'input'
        // },
        {
          name: '类型',
          value: 'type',
          type: 'select',
          data: [
            {
              value: 'STOP',
              label: '停工'
            },
            {
              value: 'SLOW',
              label: '停缓建'
            },
          ]
        },
        {
          name: '状态',
          value: 'status',
          type: 'select',
          data: [
            {
              value: 'STOP_REVIEW_SUBMITTED',
              label: '停工-审核中'
            },
            {
              value: 'SLOW_REVIEW_SUBMITTED',
              label: '停缓建-审核中'
            },
            {
              value: 'STOP_REVIEW_PAST',
              label: '停工'
            },
            {
              value: 'SLOW_REVIEW_PAST',
              label: '停缓建'
            },
            {
              value: 'STOP_REVIEW_REJECTED',
              label: '停工-审核不通过'
            },
            {
              value: 'SLOW_REVIEW_REJECTED',
              label: '停缓建-审核不通过'
            },
            {
              value: 'RESUME_REVIEW_SUBMITTED',
              label: '复工-审核中'
            },
            {
              value: 'START_REVIEW_SUBMITTED',
              label: '重新开工-审核中'
            },
            {
              value: 'START_WORKING',
              label: '在建'
            }
          ]
        },
        {
          name: '停缓建/停工原因',
          value: 'stopReasonId',
          type: 'select',
          data: []
        }
      ],
      visible: false,
      title: '新增停缓建/停工申请',

      visibles: false,
      titles: '开工/复工申请',

      // 停缓建附件上传
      reqMethod: 'post',
      listUrl: '',
      deleteUrl: '/workStoppageApply/batch-delete-file',
      uploadList: '/workStoppageApply/batch-upload-file',
      businessId: '',
      // 复工附件上传
      listUrls: '',

      uploadArrys: [],

      form: {
        creater: JSON.parse(sessionStorage.getItem('ycloud-user_info')).name,
        createTime: this.getNowTime(),
        resumeWorkDate: '',
        projectId: '',
        type: '',
        ifDongChang: '',
      }, // 新增停缓建申请

      forms: {
        creater: JSON.parse(sessionStorage.getItem('ycloud-user_info')).name,
        createTime: this.getNowTime(),
        descriptions: '',
        viewName: ''
      }, // 复工申请

      reasons: [], // 停缓建原因
      queryParam: {},
      data: [],
      // 加载数据方法 必须为 Promise 对象
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, {query: this.queryParam})
        return queryWorkStoppageApply(requestParameters).then((res) => {
          return res
        })
      },
      selectedRowKeys: [],
      selectedRows: [],
      totalDels: {},

      rules1: {
        branchId: [{ required: true, message: '请选择分公司', trigger: 'change' }],
        projectId: [{ required: true, message: '请选择项目', trigger: 'change' }],
        stopReasonId: [{ required: true, message: '请选择停缓建原因', trigger: 'change' }],
        stopDate: [{ required: true, message: '请选择停缓建时间', trigger: 'change' }],
        resumeWorkDate: [{ required: true, message: '请选择预计复工时间', trigger: 'change' }],
        situationComment: [{ required: true, message: '请输入情况说明', trigger: 'blur' }],
        imageProgress: [{ required: true, message: '请输入当前形象进度', trigger: 'change' }],
        stoppageType: [{ required: true, message: '请选择类型', trigger: 'change' }],
        ifDongChang: [{ required: true, message: '请选择是否经过董常会', trigger: 'change' }],
      },
      rules2: {
        situationComment: [{ required: true, message: '请输入情况说明', trigger: 'blur' }]
      },
      // 流程配置
      processConfig: null,
      processConfig1: null,
      processConfig2: null,
      processConfig3: null,
      //点击提交发送流程配置值
      setProcessConfig: null,
      // 业务id
      businessId1: null,
      businessId2: null,
      rowdata: {},
    }
  },

  async created() {
    this.getStopConTotal()
    this.getProjectCommon()
    //获取通过获取流程配置值
    // 停缓建
    this.processConfig = await this.$getConfigFn('project_suspension_application')
    // 复工
    this.processConfig1 = await this.$getConfigFn('application_return_work')

    // 停工
    this.processConfig2 = await this.$getConfigFn('project_shutdown')
    // 开工
    this.processConfig3 = await this.$getConfigFn('application_reopen')
  },
  computed: {},
  methods: {
    selectOrg(val) {
      if(val.length > 1) {
        this.form.branchComId = val[val.length - 2].orgId
        this.$set(this.form, 'projectNum', val[val.length - 1].projectCode)
      }
    },
    fileArrysData(val) {
      this.form.fileIds = val.map(item=> item.commonId)
    },
    fileArrysDatas(val) {
      this.forms.fileIds = val.map(item=> item.commonId)
    },
    handleApproveDetail(record) {
      this.visibleApprove = true
      this.businessId1 = record.id
    },
    getBranchId(val) {
      this.form.branchComId = val
    },
    getProjectId(val) {
      this.form.projectId = val
    },
    projectNumOne(val) {
      this.form.projectNum = val
    },
    disabledDate(current) {
      return current < moment(this.form.stopDate)
    },
    getProjectCommon() {
      getProjectCommon({ type: 17 }).then((res) => {
        this.reasons = res.data
        this.searchArr[3].data = this.getChangeDatatTypes(res.data)
      })
    },
    handleCancels() {
      this.visibles = false
    },
    // 开工/复工信息 - 确认
    handleOks() {
      if (this.loading) return
      this.setProcessConfig = null
      this.businessId2 = null
      let status = this.rowdata.status
      let cloneForms = cloneDeep(this.forms)

      this.$refs.form2.validate((err, value) => {
        if (err) {
          this.submitApprovalConfirm(status==='SLOW_REVIEW_PAST'?this.processConfig1:this.processConfig3, (flag)=>{
            if(!flag) {
              this.loading = false
              return
            }
            this.loading = true
            resumeWorkApply(cloneForms).then((res) => {
              this.loading = false
              if (res.code == 200) {
                this.visibles = false
                this.$message.success('申请成功!')
                this.setProcessConfig = status==='SLOW_REVIEW_PAST'?this.processConfig1:this.processConfig3
                this.businessId2 = res.data+'_resume'
                this.$refs.table.refresh(true)
              }
            })
          })
        }else {
          this.$message.warning("请填写完所有必填项信息")
        }
      })
    },
    
    // 停缓建/停工信息 - 确认
    handleOk() {
      this.setProcessConfig = null
      this.businessId2 = null; 
      if (this.loading) return
      let status = this.form.stoppageType === 'SLOW'
      if (this.form.workStoppageId) {
        this.$refs.form1.validate((err, value) => {
          if(this.form.ifDongChang === false) return this.$message.warning("项目停缓建必须经过董常会之后才能进行申请流程")
          if (err) {
            this.loading = true
            this.submitApprovalConfirm(status? this.processConfig : this.processConfig2, (flag)=>{
              if(!flag) {
                this.loading = false
                return
              }
                workStoppageApplyEdit(this.form).then((res) => {
                  this.loading = false
                  if (res.code == 200 || res.data.code == 200) {
                    this.$message.success('提交成功')
                    this.businessId2 = this.form.workStoppageId
                    this.setProcessConfig = status? this.processConfig : this.processConfig2
                    this.visible = false
                    this.$refs.table.refresh(true)
                  }
                }).catch(() => {
                  this.loading = false
                })
            })
          }else {
            this.$message.warning("请填写完所有必填项信息")
          }
        })
      } else {
        this.$refs.form1.validate((err, value) => {
          if(this.form.ifDongChang === false) return this.$message.warning("项目停缓建必须经过董常会之后才能进行申请流程")
          if (err) {
            this.loading = true
            this.submitApprovalConfirm(status? this.processConfig : this.processConfig2, (flag)=>{
              if(!flag) {
                this.loading = false
                return
              }
              workStoppageApplySave(this.form).then((res) => {
                this.loading = false
                if (res.code == 200  || res.data.code == 200) {
                  this.$message.success('提交成功')
                  this.businessId2 = res.data;
                  this.setProcessConfig = status? this.processConfig : this.processConfig2
                  this.visible = false
                  this.$refs.table.refresh(true)
                }
              }).catch(() => {
                this.loading = false
              })
            })

          }else {
            this.$message.warning("请填写完所有必填项信息")
          }
        })
      }
    },
    // 复工 、重新开工
    handleReturnWork(record, type) {
      this.rowdata = record
      this.titles = type === 'RESUME'?'复工申请':'重新开工申请'
      workStoppageApplyDetail(record.id).then(res=> {
        let data = res.data
        const files = data.resumeWorkApply ? data.resumeWorkApply.fileList : []
        this.forms = {
          workStoppageId: data.id,
          projectId: data.projectId,
          viewName: data.branchComName + '/' + data.projectName,
          creater: data.resumeWorkApply ? data.resumeWorkApply.creatorName : JSON.parse(sessionStorage.getItem('ycloud-user_info')).name,
          createTime: data.resumeWorkApply ? data.resumeWorkApply.createTime : this.getNowDate(),
          resumeWorkType: type,
          situationComment: data.resumeWorkApply ? data.resumeWorkApply.situationComment : '',
          // situationComment: "",
          auditStatus: 'SUBMITTED',
          fileIds: files.map(item => item.commonId)
          
        }
        this.uploadArrys = files
        this.visibles = true
      })
    },
    search(val) {
      this.queryParam = val
      this.$refs.table.refresh(true)
      this.getStopConTotal()
    },

    handelAdd() {
      this.visible = true
      this.form = {}
      this.uploadArrys = []
      this.form.creater = JSON.parse(sessionStorage.getItem('ycloud-user_info')).name
      this.form.createTime = this.getNowDate()
      this.businessId = ''
      this.businessId1 = ''
    },

    getStopConTotal() {
      queryWorkStoppageStatistics(this.queryParam).then((res) => {
        this.totalDels = res.data
        let total = 0
        for(let key in res.data) {
          total += parseInt(res.data[key])
        }
        this.totalDels.total = total
      })
    },

    onChangeDown(val) {
      this.form.stopDate = val.format('YYYY-MM-DD')
      if (this.form.resumeWorkDate && this.form.stopDate > this.form.resumeWorkDate) {
        this.$message.error('停缓建时间不能晚于预计开工时间！')
        this.form.stopDate = ''
        return
      }
    },

    onChangeReturn(val) {
      this.form.resumeWorkDate = val.format('YYYY-MM-DD')
      if (this.form.stopDate && this.form.resumeWorkDate < this.form.stopDate) {
        this.$message.error('停缓建时间不能晚于预计开工时间！')
        this.form.resumeWorkDate = ''
        return
      }
    },

    handleDels(val) {
      // 查看年度评级想详情
      this.$router.push({ path: '/project/stop-construction/details', query: { id: val.id, statusCode: val.statusCode } })
    },

    handleEdit(e) {
      workStoppageApplyDetail(e.id).then(res=> {
        let data = res.data
        this.title = '编辑项目停缓建申请'
        this.businessId = data.id;
        this.form = {
          workStoppageId: data.id,
          stopReasonId: data.stopReason.id,
          stopDate: data.stopDate,
          resumeWorkDate: data.resumeWorkDate,
          situationComment: data.situationComment,
          imageProgress: data.imageProgress,
          stoppageType: data.stoppageType,
          ifDongChang: data.ifDongChang,
          creater: data.creatorName,
          createTime: data.createTime,
        }
        this.uploadArrys = data.fileList
        this.$nextTick(() => {
          this.form.projectId = data.projectId
          this.visible = true
        })
      })
    },

    handleCancel() {
      this.visible = false
    },
    /**
     * @description: 选择审批人关闭回调时关闭提交弹窗
     * @return {void}
     */
    closeSelectApprover() {
      this.handleCancel()
      this.handleCancels()
      this.$refs.table.refresh(true)
    }
  }
}
</script>


